/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package bean;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

/**
 *
 * @author user
 */
public class roomListBean {

    /**
     *
     */
    private Map list;

    /**
     *
     */
    public roomListBean() {
        this.list = new HashMap();
    }

    /**
     *
     * @param room
     */
    public synchronized void addRoom(roomBean room) {
        list.put(room.getName(), room);
    }

    /**
     *
     * @param name
     */
    public synchronized void removeRoom(String name) {
        list.remove(name);
    }

    /**
     *
     * @param name
     * @return
     */
    public roomBean getRoom(String name) {
        return (roomBean) list.get(name);
    }

    /**
     *
     * @return
     */
    public Set getRooms() {
        return list.entrySet();
    }

    public roomBean[] getRoomsInArrayList() {
        Set rooms = getRooms();
        roomBean[] roomArray = new roomBean[rooms.size()];
        Iterator it = rooms.iterator();
        int i = 0;
        while (it.hasNext()) {
            Map.Entry me = (Map.Entry) it.next();
            String key = (String) me.getKey();
            roomArray[i] = (roomBean) me.getValue();
            ++i;
        }
        return roomArray;
    }

}
